package com.ternnetwork.oa.repository.work;


import com.ternnetwork.oa.entity.work.Event;
import com.ternnetwork.oa.entity.work.Report;
import com.ternnetwork.oa.enums.work.ReportType;
import com.ternnetwork.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

public interface ReportRepository extends BaseRepository<Report, Long> {

    @Query("from Report t where t.start>=?1 and t.end<?2")
    List<Report> findAll(Date start, Date end);

    @Query("from Report t where  t.createdById=?1 and t.start>=?2 and t.end<?3")
    List<Report> findAll(Long createdById,Date start, Date end);

    @Query("select count(1) from Report where createdById=?1 and date=?2 and type=?3")
    Long getCountByDate(Long createdById, Long date, ReportType type);
}
